package hibernate.billStream;

import java.util.StringTokenizer;

import hibernate.p.Pair;
import hibernate.p.Unit;

public class ServiceRec 
extends ExpenseRec{
	
	private String note;
	private int piece;
	private Pair price=new Pair();
	private ServiceWrapper service;
	private Long id;
	private ConcreteBill bill;
	
	public ConcreteBill getBill(){return bill;}
	
	public void setBill(ConcreteBill bill){this.bill=bill;}
	
	public void setNote(String note){
		this.note=note;
	}
	
	public String getNote(){
		return note;
	}
	
	public void setPiece(int piece){
		this.piece=piece;
	}
	
	public int getPiece(){
		return piece;
	}
	
	public Double getPrice(){
		return ((Double)price.getFirst()).doubleValue();
	}
	
	public void setPrice(Double info){
		this.price.setFirst(info);
	}
	
	public Unit getPriceUnit(){
		return ((Unit)this.price.getSecond());
	}
	
	public void setPriceUnit(String unit){
		this.price.setSecond(Unit.parseUnit(unit));
	}
	
	public void setService(String service){
		this.service=new ServiceWrapper();
		this.service.setConcrete(service);
	}
	
	public ServiceWrapper getConcreteService(){
		return service;
	}
	
	public String getService(){
		return service.toString();
	}
	
	public void setId(Long id){
		this.id=id;
	}
	
	public Long getId(){
		return id;
	}
	
	public Commodity getCommodity() {
		// TODO Auto-generated method stub
		return service.getConcreteWrapper();
	}

	public String getName() {
		// TODO Auto-generated method stub
		return service.getConcreteWrapper().getName();
	}

	public Pair getTotalPrice() {
		// TODO Auto-generated method stub
		double t;
		t=((double)piece)*((Double)price.getFirst());
		Pair p=new Pair(t,price.getSecond());
		
		return p;
	}

	public int getUnitNr() {
		// TODO Auto-generated method stub
		return 0;
	}
	
	public boolean equals(Object obj){
		if(!(obj instanceof ServiceRec))
			return false;
		else return ((ServiceRec)obj).id.equals(this.id);
	}
	
}
